﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;

namespace sistemaAcademicoFinanceiroEscolas
{
    public partial class aulaEfetivar2 : System.Web.UI.Page
    {
        public SqlConnection conexao = new SqlConnection(ConfigurationManager.AppSettings["baseDados"]);
        public SqlCommand cmdPrincipal;
        public SqlDataReader drPrincipal;
        public string sql;

        public SqlConnection conexaoGrupo = new SqlConnection(ConfigurationManager.AppSettings["baseDados"]);
        public SqlCommand cmdPrincipalGrupo;
        public SqlDataReader drPrincipalGrupo;
        public string sqlGrupo;

        public string efetiva;
        public string observacao;

        public SqlConnection conexaoUpdate = new SqlConnection(ConfigurationManager.AppSettings["baseDados"]);
        public SqlCommand cmdUpdate;
        public string update;

        public validarValores vV = new validarValores();

        int contador;
        int resto;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                // Inserindo a data atual do computador
                txtData.Text = DateTime.Now.ToString("dd/MM/yyyy");



            }
        }

        void aula()
        {

            SqlConnection sqlc = new SqlConnection(ConfigurationManager.AppSettings["baseDados"]);
            sqlc.Open();
            SqlConnection sqld = new SqlConnection(ConfigurationManager.AppSettings["baseDados"]);
            sqld.Open();

 
            string conteudo = "", selectAula = "";
           
             conteudo += "<div id=\"accordion\">";
            int cont = 0;

            if (drAnoLetivo.HasRows)
            {
                while (drAnoLetivo.Read())
                {
                    if (Convert.ToInt16(drAnoLetivo["descricaoAnoLetivo"]) <= Convert.ToInt16(DateTime.Now.Year))
                    {
                        if (cont == 0)
                        {
                            conteudo += "<h2 class=\"current\">" + drAnoLetivo["descricaoAnoLetivo"].ToString() + "</h2>";
                            conteudo += "<div class=\"pane\" style=\"display:block\">";
                        }
                        else
                        {
                            conteudo += "<h2>" + drAnoLetivo["descricaoAnoLetivo"].ToString() + "</h2>";
                            conteudo += "<div class=\"pane\">";
                        }
                        conteudo += "<table width=\"100%\"><tr><th align=\"center\"><h3>Aulas</h3></th></tr></table>";


            try
            {
                conexao.Open();
                conexaoGrupo.Open();
           



                sql = "SELECT codigoAula, codigoProfessor, (select nomeProfessor from professor where aula.codigoProfessor = professor.codigoProfessor) as nomeProfessor, \n";
                sql += "codigoAluno, (select nomeAluno from aluno where aula.codigoAluno = aluno.codigoAluno) as nomeAluno, codigoGrupo, dataAula, horaInicialAula, \n";
                sql += "horaFinalAula, codigoDisciplina, descricaoAssuntoAula, observacoesAula,  \n";
                sql += "aulaRealizada, valorHora, valorTotalSemDesconto, valorTotalComDesconto, codigoAnoLetivo, falta, meiaHora \n";
                sql += "FROM aula WHERE (dataAula = '" + txtData.Text + "') order by CONVERT(INT, SUBSTRING(horaInicialAula,1 , 2))";



                contador = 0;

                string tabela = "<table>";
              
                string horaInicialAula = "";
                string horaFinalAula = "";
                string horaIniciaAulaAnterior = "";
                string horaFinalAulaAnterior = "";
                cmdPrincipal = new SqlCommand(sql, conexao);
                drPrincipal = cmdPrincipal.ExecuteReader();

                TimeSpan qtdAula = Convert.ToDateTime(horaFinalAula).Subtract(Convert.ToDateTime(horaInicialAula));


            }
        }
    }
}
